# ADMIN: Used to add/remove/edit prizes

class Admin::PrizesController < Admin::BaseController
  def new
    @prize = Prize.new
  end

  def index
    @prizes = Prize.paginate :page=>params[:page]
  end

  def edit
    @prize = Prize.find params[:id]
  end

  def create
    @prize = Prize.new params[:prize]
    if @prize.save
      flash[:notice]='successful created.'
      redirect_to admin_prizes_path
    else
      render :action=>'new'
    end
  end

  def update
    @prize = Prize.find params[:id]
    if @prize.update_attributes params[:prize]
      flash[:notice]='successful updated'
      redirect_to admin_prizes_path
    else
      render :action=>'edit'
    end
  end

  def destroy
    @prize = Prize.find params[:id]
    @prize.destroy
    flash[:notice]='successful deleted.'
    redirect_to admin_prizes_path
  end
end
